package com.cssy.yd.basic.util;

import com.cssy.yd.basic.entity.BasicMaterialsDO;
import com.plat.helper.SearchConditions;

public class MaterailsUtil {
	public void getCode(BasicMaterialsDO bMaterialsDO,String list){
		if(list!=null){
			bMaterialsDO.setSerialNumber(Integer.parseInt(list)+1);
			String s = (Integer.parseInt(list)+1)+"";
				if(s.length() == 1){
					bMaterialsDO.setCode(bMaterialsDO.getPlaceCode()+bMaterialsDO.getMaterialTypeCode()+bMaterialsDO.getMaterialNumberCategoryCode()+"-000"+s+"-"+bMaterialsDO.getSupplierCode());
				}else if(s.length() == 2){
					bMaterialsDO.setCode(bMaterialsDO.getPlaceCode()+bMaterialsDO.getMaterialTypeCode()+bMaterialsDO.getMaterialNumberCategoryCode()+"-00"+s+"-"+bMaterialsDO.getSupplierCode());
				}else if(s.length() == 3){
					bMaterialsDO.setCode(bMaterialsDO.getPlaceCode()+bMaterialsDO.getMaterialTypeCode()+bMaterialsDO.getMaterialNumberCategoryCode()+"-0"+s+"-"+bMaterialsDO.getSupplierCode());
				}else if(s.length() == 4){
					bMaterialsDO.setCode(bMaterialsDO.getPlaceCode()+bMaterialsDO.getMaterialTypeCode()+bMaterialsDO.getMaterialNumberCategoryCode()+"-"+s+"-"+bMaterialsDO.getSupplierCode());
				}
		}else{
			bMaterialsDO.setSerialNumber(1);
			bMaterialsDO.setCode(bMaterialsDO.getPlaceCode()+bMaterialsDO.getMaterialTypeCode()+bMaterialsDO.getMaterialNumberCategoryCode()+"-0001"+"-"+bMaterialsDO.getSupplierCode());
		}
	}
}
